home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Think Class Libraries / WASTE TCL 1.8 / WASTE TCL 1.8 ƒ / CWASTETask.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-12  |  2.6 KB  |  126 lines  |  [TEXT/MMCC]

  1. /************************************************************************\
  2.  CWASTETask.cpp
  3.  
  4.     A task for dealing with undo for CWASTEText objects under WASTE 1.1
  5.  
  6.  by Dan Crevier
  7.  11/4/95
  8.  
  9.  version 1.8
  10.  
  11.  based on code by Jud Spencer
  12.  
  13.  Roms    95/11/08    adapted to THINK C / TCL 1.1.3
  14. \************************************************************************/
  15.  
  16. #include "CWASTETask.h"
  17. #include "CWASTEText.h"
  18.  
  19. #define undoDrag    6
  20.  
  21. /************************************************************************\
  22.     Constructor - save a pointer to the CWASTEText
  23. \************************************************************************/
  24.  
  25. #ifndef THINK_C
  26. CWASTETask::CWASTETask(CWASTEText *text)
  27.     : CTask(0)
  28. {
  29. #else
  30. void CWASTETask::IWASTETask(CWASTEText *text)
  31. {
  32.     ITask(0);
  33. #endif // THINK_C
  34.       wasteText = text;
  35. }
  36.  
  37. /************************************************************************\
  38.     Destructor - tell text object that we aren't around any more
  39. \************************************************************************/
  40.  
  41. #ifndef THINK_C
  42. CWASTETask::~CWASTETask()
  43. #else
  44. void CWASTETask::Dispose()
  45. #endif // THINK_C
  46. {
  47.     if (wasteText->itsLastTask == this)
  48.         wasteText->itsLastTask = NULL;
  49.  
  50. #ifdef THINK_C
  51.     CTask::Dispose();
  52. #endif
  53.  
  54. }
  55.                         
  56. /************************************************************************\
  57.     GetNameIndex - give a pointer to the name of the undo action
  58. \************************************************************************/
  59.  
  60. short CWASTETask::GetNameIndex()
  61. {
  62.     short offset = -1;
  63.     Boolean undone;
  64.         
  65.     switch (wasteText->GetUndoInfo(&undone))
  66.     {
  67.         case weAKTyping:
  68.             offset = undoTyping;
  69.             break;
  70.             
  71.         case weAKCut:
  72.             offset = undoCut;
  73.             break;
  74.             
  75.         case weAKPaste:
  76.             offset = undoPaste;
  77.             break;
  78.             
  79.         case weAKClear:
  80.             offset = undoClear;
  81.             break;
  82.             
  83.         case weAKDrag:
  84.             offset = undoDrag;
  85.             break;
  86.  
  87.         case weAKSetStyle:
  88.             offset = undoFormatting;
  89.             break;
  90.     }
  91.     if ( offset >= 0)
  92.     {
  93.         return (offset + CWASTEText::cFirstTaskIndex);
  94.     }
  95.     else
  96.     {
  97.         return ( 0);
  98.     }
  99. }
  100.  
  101. /************************************************************************\
  102.     Undo - tell the CWASTEText to call WEUndo()
  103. \************************************************************************/
  104.  
  105. void CWASTETask::Undo()
  106. {
  107.     wasteText->BecomeGopher(true);
  108.     wasteText->Prepare();
  109.     wasteText->DoUndo();
  110.     wasteText->AdjustBounds();
  111.     wasteText->ScrollToSelection();
  112. }
  113.  
  114. /************************************************************************\
  115.     IsUndone - return true if it's a "redo"
  116. \************************************************************************/
  117.  
  118. Boolean CWASTETask::IsUndone()
  119. {
  120.     Boolean undone;
  121.     
  122.     wasteText->GetUndoInfo( &undone);
  123.  
  124.     return undone;
  125. }
  126.